package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserAddressBookMapper {

   @Insert("insert into sky_take_out.address_book(user_id, consignee, sex, phone, province_code, province_name, city_code, city_name, district_code, district_name, detail, label) " +
           "VALUES(#{userId},#{consignee},#{sex},#{phone},#{provinceCode},#{provinceName},#{cityCode},#{cityName},#{districtCode},#{districtName},#{detail},#{label}) ")
    void add(AddressBook addressBook);
@Select("select *from sky_take_out.address_book where user_id=#{currentId}")
    List<AddressBook> list(Long currentId);


    void updateAddressBook(AddressBook addressBook);
@Select("select *from sky_take_out.address_book where is_default='1'")
    AddressBook setDefult();
@Select("select *from sky_take_out.address_book where id=#{id}")
    AddressBook setById(Long id);
@Delete("delete from sky_take_out.address_book where id=#{id}")
    void DeleteAddressBook(Long id);
@Update("update sky_take_out.address_book set is_default= 0 where user_id =#{currentId}")
    void updateDefault(Long currentId);
}
